// $(function () {
    $('.side-nav').on('click', function () {
        $(this).children('a').css('backgroundColor', '#009688')
        $(this).siblings('.side-nav').children('a').css('backgroundColor', '')
    })

    function getUserInfo(){
        $.ajax({
        type:'get',
        url:'/my/user/userinfo',
        success:function (res) {
            if(res.status === 0){
                let name = res.data.nickname || res.data.username;
                $('.username').text(name);
                if (res.data.user_pic) {
                    $('.layui-nav-img').attr('src', res.data.user_pic).show().prev().hide();
                }else{
                    let first = name.substring(0, 1).toUpperCase();
                    $('.text-avater').text(first).css('display', 'inline-block')
                }
            }
        },
    })
    }
    getUserInfo();

    $('#logout').on('click', function (e) {
        console.log(1);
        e.preventDefault();
        layer.confirm('你真的要退出？出去了就进不来了喔', function(index){
            localStorage.removeItem('token');
            location.href = '../index.html';
  
            layer.close(index);
        });     
    })
